package com.bookstore.utils;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import com.bookstore.commons.beans.User;

public class LoginTag extends SimpleTagSupport {

	
	@Override
	public void doTag() throws JspException, IOException {
		PageContext context = (PageContext) this.getJspContext();
		User login_user = (User) context.getSession().getAttribute("login_user");
		HttpServletResponse response =  (HttpServletResponse) context.getResponse();
		HttpServletRequest request = (HttpServletRequest) context.getRequest();
		if(login_user == null){
			response.sendRedirect(request.getContextPath()+"/client/error/privilege.jsp");
		}
		
	}

	
}
